import store from '../../store'

export default {
  name: 'StockRank',
  data () {
    return {
      tableData: [],
      pageNo: 1,
      pageCount: 100
    }
  },
  mounted () {
    this.getTableData(this.pageNo)
  },
  methods: {
    getTableData () {
      store.dispatch('stockRank', this.pageNo)
        .then(response => {
          this.pageCount = response.data.data.allPages
          this.tableData = response.data.data.rank
        })
        .catch(error => {
          console.log('connect failed')
          console.log(error)
        })
    },
    handleCurrentChange (val) {
      this.pageNo = val
      this.getTableData()
    },
    clickRow (row) {
      this.$emit('changeStock', row.code, row.name)
    }
  }
}
